package com.sms.core.utils;

import org.apache.commons.lang3.StringUtils;

import com.sms.client.exception.SendSmsException;
import com.sms.core.request.SmsRequest;

/**
 * @desc sms工具类
 * @author WuJiangWu
 * @date 2018年7月22日下午7:31:46
 */
public class SmsUtils {

	/**
     * smsRequest参数校验
     * @param ssr
     * @throws SendSmsException
     */
    public static void validRequest(SmsRequest ssr) throws SendSmsException {
        if (StringUtils.isBlank(ssr.getAppId())) {
        	throw new SendSmsException("缺少appId参数");
        } else if (StringUtils.isBlank(String.valueOf(ssr.getTimestamp())) ) {
        	throw new SendSmsException("缺少timestamp参数");
        } else if (StringUtils.isBlank(String.valueOf(ssr.isDebug())) ) {
        	throw new SendSmsException("缺少isDebug参数");
        } else if (StringUtils.isBlank(ssr.getMobile())) {
        	throw new SendSmsException("缺少mobile参数");
        } else if (StringUtils.isBlank(ssr.getContent()) || StringUtils.isBlank(ssr.getTemplateCode())) {
        	throw new SendSmsException("缺少content,templateCode参数其中一个");
        }
    }
}
